﻿using System;
using System.Collections.Generic;
using System.Text;
using Ghasam.Business.Domain.Entity;
using Ghasam.Business.DAO;
using Spring.Transaction.Interceptor;

namespace Ghasam.Business.Services.Impl
{
    public class InternalAccountService:IInternalAccountService
    {
        private IInternalAccountDao internalAccountDao;
        public IInternalAccountDao InternalAccountDao
        {
            set { internalAccountDao = value; }
            get {return internalAccountDao; }
        }

        [Transaction(ReadOnly = false)]
        public void SaveOrUpadate(InternalAccount account)
        {
            account.ModifyStamp = DateTime.Now;
            internalAccountDao.SaveOrUpdate(account);
        }

        [Transaction(ReadOnly = false)]
        public void DeleteAccount(int Id) {
            internalAccountDao.Delete(internalAccountDao.FindById(Id));
        }

        public InternalAccount GetById(int Id) {
            return internalAccountDao.FindById(Id);
        }

        public IList<InternalAccount> FindAllAccounts()
        {
            return internalAccountDao.FindAll();
        }

        public IList<InternalAccount> SortInternalAccount(string param, bool asc)
        {
            return InternalAccountDao.SortInternalAccount(param, asc);
        }
    }
}
